package secondPart;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Auther : yxpweb
 * @Date : 2021/8/10 11:27
 * @Description: atomicInteger 解决多线程的竞争
 * https://blog.csdn.net/mryang125/article/details/81879096
 */
public class ThreadDemo16 {

    private static AtomicInteger atomicInteger = new AtomicInteger(0);

    private static Runnable gameTask = () -> {
        System.out.println(atomicInteger.get() + "Thread start begin ");
        List<Integer> list = new ArrayList<>();
        list.addAll(Arrays.asList(1, 2));
//        while (!list.isEmpty()) {
//            Integer remove = list.remove(1);
//            list.add(remove);
//            System.out.println("-------------------");
//        }

        throw new NullPointerException();
    };

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        Future future = null;
//            Object o = future.get(3, TimeUnit.SECONDS);
//            System.out.println(o);
        executorService.shutdown();
    }
}
